import routes from "../router/index"
import {createSlice} from "@reduxjs/toolkit";

let initialState = {
    publicRoutes:[...routes],  //默认路由,公共路由
    privateRoutes:[]    //私有路由
}

const accountSlice = createSlice({
    name:"account_slice",
    initialState,
    reducers:{
        updateRoute(state,action){
            console.log("收到，默认路由:",state.publicRoutes)
            console.log("收到，准备更新路由：",action.payload)
            // state.routes=[...action.payload]; //追加
            // const privateRoutes = action.payload.map(route => route.routes);
            state.privateRoutes=[...action.payload]; //追加
        }
    }
})

export const {updateRoute} = accountSlice.actions;
export default accountSlice.reducer;